#include "stdafx.h"
#include "AstType.h"
#include "FloatPointerGen.h"
using namespace llvm;

FloatPointerGen::FloatPointerGen(double v, bool is) : value(v), isDouble(is) {
	type = isDouble ? AstType::doubleType : AstType::floatType;
}

llvm::Value * FloatPointerGen::generateCode(llvm::Module * m, llvm::Function * func, llvm::IRBuilder<>&builder)
{
	auto &context = builder.getContext();
	if (isDouble)
		return ConstantFP::get(context, APFloat(value));
	else
		return ConstantFP::get(context, APFloat((float)value));
}
